# -*- coding: utf-8 -*-
import os
import re

from google.appengine.api import users

def common_template_values(uri):
    r = 'http://.*?/'
    main_url = re.findall(r,uri)
    template_values = {
            'current_user': users.get_current_user(),
            'isadmin': users.is_current_user_admin(),
            'login_url': users.CreateLoginURL(uri),
            'logout_url': users.CreateLogoutURL(uri),
            'main_url' :main_url[0][:-1],
            }
    return template_values

base_path = os.path.dirname(os.path.dirname(__file__))
control_path = os.path.join(base_path,'controls')
view_path = os.path.join(base_path,'views')
model_path = os.path.join(base_path,'models')
static_path = os.path.join(base_path,'static')
css_path = os.path.join(static_path,'css')
img_path = os.path.join(static_path,'img')
javascriptpath = os.path.join(static_path,'path')

def get_template_name(name):
    template_name = os.path.join(view_path, name)
    return template_name if os.path.isfile(template_name) else None

